package com.kingyun.gpsinspection.purificationservice.services.som.innerservice.impl;

import com.cqhilink.api.common.utils.UniqueUtil;
import com.kingyun.gpsinspection.purificationservice.dao.mapper.som.TaskRelationMapper;
import com.kingyun.gpsinspection.purificationservice.facade.model.som.TaskRelation;
import com.kingyun.gpsinspection.purificationservice.facade.service.som.SomTaskRelationService;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * 任务依赖实现类
 * Created by yangcs on 2017/3/2.
 */
public class SomTaskRelationServiceImpl implements SomTaskRelationService {

    @Autowired
    private TaskRelationMapper taskRelationMapper;

    /**
     * 插入
     * @param masterTaskId      主任务id
     * @param masterTaskType    主任务类型
     * @param relatedTaskId     从任务id
     * @param relatedTaskType   从任务类型
     * @return
     */
    @Override
    public int insert(String masterTaskId, int masterTaskType, String relatedTaskId, int relatedTaskType) {
        TaskRelation taskRelation = new TaskRelation();
        taskRelation.setMasterTaskId(masterTaskId);
        taskRelation.setMasterTaskType(masterTaskType);
        taskRelation.setRelatedTaskId(relatedTaskId);
        taskRelation.setRelatedTaskType(relatedTaskType);
        taskRelation.setTaskRelationId(UniqueUtil.uuid());
        return taskRelationMapper.insert(taskRelation);
    }
}
